<?php /*
@session_start();
 if((!isset($_SESSION["kt_login_id"]) && !isset($_SESSION["kt_login_user"]) &&  !isset($_SESSION["kt_login_level"])) ) {

    header("Location: login.php");
    exit;
	
}else{

$level = addslashes($_SESSION['kt_login_user']);
$user = addslashes($_SESSION['kt_login_level']);

echo $level;
echo $user;
}*/

require_once("classes/respondent.class.php");
require_once("classes/language.class.php");
require_once("classes/country.class.php");
require_once("classes/nationality.class.php");
require_once("classes/newsletter.class.php");

//Instanciando Objetos
$respondent 	= new Respondent();
$language 		= new Language();
$country 		= new Country();
$nationality 	= new Nationality();
$newsletter 	= new Newsletter();

//Invocando metodo

$listLanguage		= $language->listObject();
$listCountry 		= $country->listObject(); 
$listNationality	= $nationality->listObject(); 
$listNewsletter		= $newsletter->listObject(); 



if(isset($_POST['action'])&& $_POST['action']=='filter'){

	$fk_country		= $_POST['country'];
	$fk_language	= $_POST['language'];
	$fk_nationality	= $_POST['nationality'];
	$sex			= $_POST['sex'];
	$name			= $_POST['name'];
	$familyname		= $_POST['surname'];
	$birthday		= $_POST['birthday'];
	$registroem		= $_POST['registered'];

$dadosFiltro = array('fk_country'=>$fk_country, 'fk_language'=>$fk_language, 'fk_nationality'=>$fk_nationality, 'sex'=>$sex,
  'name'=>$name, 'familyname'=>$familyname, 'birthday'=>$birthday, 'registroem'=>$registroem);
  $listRespondent 	= $respondent->filterObject($dadosFiltro);
  //echo($listRespondent);


}else{
	$listRespondent = $respondent->listObject();

}
//$listRespondent 	= $respondent->listObject($dadosFiltro);

//$listRes = mysql_fetch_assoc($listRespondent);
//$listLan = mysql_fetch_assoc($listLanguage);
//$listCou = mysql_fetch_assoc($listCountry);
//$listNat = mysql_fetch_assoc($listNationality);

//$CamposRes = array_keys($list);

//$respondent = new Respondent();
$list = mysql_fetch_assoc($listRespondent);
if($list!=NULL){
$arrCampo = array_keys($list);
$arrValores = array_values($list);	
}


$i = 1;

//$arrValores = array_values($list);
//$i = 1;
print_r( $listRespondent);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/user.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Print Controller</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEditableHeadTag -->
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>

<script type="text/javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
var indexSelect = document.getElementById("newsletterS").selectedIndex;
var valueSelected = newsletterS.options[indexSelect].value;
  window.open(theURL,winName,features);
}
function preview(){
//var indexSelect = document.getElementById("newsletterS").selectedIndex;
//var valueSelected = newsletterF.newsletterS.options[indexSelect ].value;

//window.open(newsletterpage.php?id=valueSelectted,null,null,null);

}





//-->
</script>
<!-- InstanceEndEditable -->
<style type="text/css" media="all">
<!--
@import url("css/basics.css");
-->
</style>
<!-- TinyMCE -->
<script type="text/javascript" src="includes/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
mode : "textareas",
		theme : "advanced",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
	});
</script>
<!-- /TinyMCE -->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>


<body>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="79%" rowspan="2"><img src="images/logo.png" width="293" height="112" /></td>
    <td width="21%"><p>Version: 1.0</p>
    <p>Status: Beta</p></td>
  </tr>
  <tr>
    <td><!-- InstanceBeginEditable name="logout" -->logout<!-- InstanceEndEditable --> </td>
  </tr>
  <tr>
    <td colspan="2" background="images/bg.png" style="padding-left:10px;"><table width="59%" border="0" cellspacing="1" cellpadding="1">
    <?php
		//if ($level == 0){
	?>
        <tr>
          <td height='35'><a href='index.php'>Home</a></td>
         <!-- <td><a href='../suprimentos.php' target='_parent'>Suprimentos</a></td>-->
        </tr>
    <?php
   // }else
	//	{ 
	//	if ($level == 1){
	?>
        <tr>
          <td height='35'><a href='index.php'>Home</a></td>
          <td><a href='ListaRegistrados.php' target='_parent'>Registed</a></td>
          <td><a href="newsletterList.php" target='_parent'>Newsletter</a></td>
          <td><a href="directMailList.php" target='_parent'>Direct Mail</a></td>

        </tr>
    <?php
 //   }
	
//	}
	
	?>
	
	
    
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><!-- InstanceBeginEditable name="content" -->  
   <div class="KT_tng" >
      <h1> Qls_respondents</h1>
      <div class="msgerror" id="msgerror">
      <?php ?>
      </div>
<div style="background:#CDCDCD; display:block;">
	<h2>FILTRO</h2>
     	<form name="filterForm" action="" method="POST" enctype="multipart/form-data">
		<table width="654" border="0" cellspacing="2">
  <tr>
    <td width="50px">Country</td>
    <td><select name="country" id="country" style="width:200px;">
	<option value="">Select</option>
		<?php	
			while($listCou =mysql_fetch_assoc($listCountry) ){
			echo '<option value="'.$listCou['idcountry'].'">'.$listCou['countryname'].'</option>';
			}
		?>
		</select></td>
    <td width="50px">Language</td>
    <td ><select name="language" id="language" style="width:200px;">
	<option value="">Select</option>
		<?php	
			while($listLan =mysql_fetch_assoc($listLanguage) ){
			echo '<option value="'.$listLan['idlanguage'].'">'.$listLan['languagename'].'</option>';
			}
		?>
    </select></td>
    <td width="50px">Nationality</td>
    <td><select name="nationality" id="nationality" style="width:200px;">
	<option value="">Select</option>
		<?php	
			while($listNat =mysql_fetch_assoc($listNationality) ){
			echo '<option value="'.$listNat['idnationality'].'">'.$listNat['nationalityname'].'</option>';
			}
		?>
    </select></td>
  </tr>
  <tr>
    <td >Sex</td>
    <td><select name="sex" id="sex" style="width:200px;">
	<option value="">Select</option>
	<option value="F">Female</option>
	<option value="M">Male</option>
    </select></td>
    <td>Name</td>
    <td><input type="text" name="name" id="name" style="width:195px;" /></td>
    <td>Surname</td>
    <td><input type="text" name="surname" id="surname" style="width:195px;" /></td>
  </tr>
  <tr>
    <td>Birthday</td>
    <td><input type="text" name="birthday" id="birthday" style="width:195px;" /></td>
    <td>Registered</td>
    <td><input type="text" name="registered" id="registered" style="width:195px;" /></td>
    <td>&nbsp;</td>
    <td>
	<input type="hidden" name="action" id="action" value="filter" style="width:195px;" />
	<input type="submit" name="submit" id="submit" value="Filter" style="width:195px;" /></td>
  </tr>
</table>
		
	
		</form>
		
		</div>


		<div style="background:#CDCDCD; display:block;">
		<h2>NEWSLETTER</h2>
<form action="newslatterpage.php" target="_blank" method="get">
		<table><tr>		<td width="50px">Select the Newsletter</td>
    <td ><select name="newsletter" id="newsletter">
	<option value="">Select</option>
		<?php	
			while($listNews =mysql_fetch_assoc($listNewsletter) ){
			echo '<option value="'.$listNews['id'].'">'."Ano: ".$listNews['ano']." - No.: ".$listNews['numero']." - Mês: ".$listNews['mes'].'</option>';
			}
		?>
    </select></td><td> <input name="preview" type="submit" id="preview" value="Preview" /></td></tr>

	</table></form>
		</div>
		
		
<form  name="send"  action="directMailSend.php" method="POST" enctype="multipart/form-data">
	  <?php 
  echo"<table class = 'listTable' >	<tr>
  <th></th>
  ";

foreach($arrCampo as $campo){
	echo "
<th>".$campo."</th>
	
	";
}
echo "
<th colspan= '3'>:: FUNCTIONS ::</th>


</tr>";
//$res1 = $db->seleciona("SELECT * FROM qls_countries");
	   while($list =mysql_fetch_assoc($listRespondent) ){
	   
	   if (($i % 2) == 1){ $fundo="#FEFEFE"; }else{ $fundo="#CDCDCD"; }
$i++;
			echo "			
			<tr bgcolor=$fundo>";
$arrValores = array_values($list);
echo '<td><input id="uid" name="uid_'.$list['ID'].'" type="checkbox" value="'.$list['ID'].'"></td>';
foreach($arrValores as $valor){
	echo "
<td>".$valor."</td>
	
	";
}
echo "


<td>View</td>
<td>View</td>
<td>View</td>
<td>View</td>

</tr>";
			
			
		}
	echo '
	<tr><td colspan="15"><input type="submit" value="submit" name="submit"></td></tr>
	
	</table>';
	

   ?>
      </div><!-- InstanceEndEditable --></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

</body>
<!-- InstanceEnd --></html>
